<?php
/**
 * Created by PhpStorm.
 * User: yzh
 * Date: 2019/5/11
 * Time: 15:57
 */

namespace app\api\model;


class PosterClass extends BaseModel
{

    protected $autoWriteTimestamp = true;

    protected $hidden = ['create_time','update_time'];

    /**
     * 与posterMaterial一对多关系
     * @return \think\model\relation\HasMany
     */
    public function poster(){
        return $this->hasMany('PosterMaterial','style','id');
    }

    /**
     * 获取海报素材数据
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getClass(){
        $result = self::where('status = 1')->with(['poster'=>function($query){
            $query->where('status = 1')->with(['image'])->order('create_time','desc');
        }])->order('order','desc')->select();
        return $result;
    }







}